// 格式化时间
export function formatTime(time: number): string {
  const date = new Date(time);
  const now = new Date();
  const Y = date.getFullYear();
  const M = date.getMonth() + 1;
  const D = date.getDate();
  const h = date.getHours();
  const m = date.getMinutes();

  const Y0 = now.getFullYear();
  const M0 = now.getMonth() + 1;
  const D0 = now.getDate();

  if (Y === Y0) {
    if (M === M0 && D === D0) return `今天 ${h}:${m < 10 ? '0' + m : m}`;
    if (M === M0 && D === D0 - 1) return `昨天 ${h}:${m < 10 ? '0' + m : m}`;
    return `${M}月${D}日 ${h}:${m < 10 ? '0' + m : m}`;
  }
  return `${Y}年${M}月${D}日 ${h}:${m < 10 ? '0' + m : m}`;
}
